package com.gzhu.knowledgeAdmin.controller;


import com.gzhu.knowledgeAdmin.common.dto.TemplateQueryRequest;
import com.gzhu.knowledgeAdmin.common.result.R;
import com.gzhu.knowledgeAdmin.entity.VariableType;
import com.gzhu.knowledgeAdmin.service.VariableTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
public class VariableTypeController {

    @Autowired
    private VariableTypeService variableTypeService;

    @GetMapping("/template/variables/list")
    public R getVariables() {

        List<String> variables = variableTypeService.getVariables();

        return R.ok(variables);
    }

    @PostMapping("/template/variables/allList")
    public R getVariablesList(@RequestBody TemplateQueryRequest templateQueryRequest) {

        List<VariableType> variableTypeList = variableTypeService.getVariablesList();

        return R.ok(variableTypeList);
    }

    @PostMapping("/template/variables/add")
    public R addVariable(String name){

        variableTypeService.addVariable(name);

        return R.ok(true);
    }

    @PostMapping("/template/variables/delete")
    public R deleteVariable(Integer id){

        variableTypeService.deleteVariable(id);

        return R.ok(true);
    }

}
